<!DOCTYPE html>
<html>
<head>
    <title>相机温度监控</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.css">
    <style>
        body {
            background-color: #fff;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        .title-container {
            background-color: #000;
            margin-bottom: 20px;
            padding: 15px 0;
            text-align: center;
            width: 100%;
        }
        .page-title {
            color: #fff;
            display: inline-block;
            margin: 0;
            padding: 0;
        }
        .faulty {
            color: #dc3545;
            font-weight: bold;
        }
        .faulty-list {
            max-height: 150px;
            overflow-y: auto;
            background-color: #f8f9fa;
            padding: 10px;
            border-radius: 5px;
            margin-top: 5px;
            border: 1px solid #dee2e6;
        }
        .faulty-camera {
            color: #dc3545;
            font-size: 0.9em;
        }
        .card {
            background-color: #fff;
            color: #212529;
            border: 1px solid #dee2e6;
        }
        .card-header {
            background-color: #f8f9fa !important;
            color: #212529;
        }
        .table {
            color: #212529;
            background-color: #fff;
        }
        .table-striped tbody tr:nth-of-type(odd) {
            background-color: rgba(0,0,0,0.02);
        }
        .table th, .table td {
            border-top: 1px solid #dee2e6;
        }
        .table thead th {
            border-bottom: 2px solid #dee2e6;
        }
    </style>
</head>
<body>
    <div class="container py-4">
        <div class="title-container">
            <h1 class="page-title">相机温度监控</h1>
        </div>
        
        <div class="card">
            <div class="card-header bg-dark">
                <h5 class="mb-0">历史温度记录</h5>
            </div>
            <div class="card-body">
                <table class="table table-striped">
                    <thead class="thead-dark">
                        <tr>
                            <th>观测日期</th>
                            <th>相机总数</th>
                            <th>故障相机数</th>
                            <th>故障相机列表</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for day in days %}
                        <tr>
                            <td>{{ day.date }}</td>
                            <td>{{ day.cameras }}</td>
                            <td class="{% if day.faulty > 0 %}faulty{% endif %}">
                                {{ day.faulty }}
                            </td>
                            <td>
                                {% if day.faulty > 0 %}
                                <div class="faulty-list">
                                    {% for cam_id, cam_data in day.faulty_cameras.items() %}
                                    <div class="faulty-camera">
                                        {{ cam_id }} (最大温差: {{ cam_data.max_diff|round(2) }}°C)
                                    </div>
                                    {% endfor %}
                                </div>
                                {% endif %}
                            </td>
                            <td>
                                <a href="/day/{{ day.date }}" class="btn btn-sm btn-primary">查看详情</a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>